import { defHttp } from '@/utils/http';

// 登录方法
export function login(data: any) {
  return defHttp.post(
    {
      url: '/login',
      data: data,
    },
    {
      errorMessageMode: 'message',
      isReturnNativeResponse: true,
    },
  );
}

// 退出方法
export function logout() {
  return defHttp.post(
    {
      url: '/logout',
    },
    {
      errorMessageMode: 'message',
    },
  );
}

// 获取用户详细信息
export function getInfo() {
  return defHttp.get(
    {
      url: '/getInfo',
    },
    {
      errorMessageMode: 'message',
      isReturnNativeResponse: true,
    },
  );
}

// 获取验证码
export function getCodeImg() {
  return defHttp.get(
    {
      url: '/captchaImage',
      timeout: 20000,
    },
    {
      errorMessageMode: 'message',
      isReturnNativeResponse: true,
    },
  );
}

// 判断手机号是否注册
export function phoneIsRegister(params: any) {
  return defHttp.get(
    {
      url: '/phoneIsRegister',
      headers: {
        isToken: false,
      },
      params,
      timeout: 20000,
    },
    {
      errorMessageMode: 'message',
      isReturnNativeResponse: true,
    },
  );
}

// 发送手机验证码
export function sendSmsCode(params: any) {
  return defHttp.get(
    {
      url: '/sendSysVerifyCode',
      headers: {
        isToken: false,
      },
      params,
      timeout: 20000,
    },
    {
      errorMessageMode: 'message',
      isReturnNativeResponse: true,
    },
  );
}
